<?php

//1、通过$_FILES文件上传变量接受上传文件信息

$fileInfo = $_FILES['myFile'];
$filename = $fileInfo['name'];
$type = $fileInfo['type'];
$tmp_name = $fileInfo['tmp_name'];
$size = $fileInfo['size'];
$error = $fileInfo['error'];


//2、判断错误号，只有为0或者是UPLOAD_ERR)OK，没有错误发生，上传成功

if($error == UPLOAD_ERR_OK){
	if(move_uploaded_file($tmp_name,"ache/".$filename)){
		echo '文件'.$filename.'上传成功';
	}else{
		echo '文件'.$filename.'上传失败';
	}
}else{
	switch ($error) {
		case 1:
			echo '上传的文件超过了php.ini中upload_max_filesize选项限制的值';
			break;
		case 2:
			echo '上传文件的大小超过了HTML表单中max_file_size选项指定的值';
			break;
		case 3:
			echo '文件只有部分被上传';
			break;
		case 4:
			echo '没有文件被上传';
			break;
		case 6:
			echo '找不到临时文件夹';
			break;
		case 7:
			echo '文件写入失败';
			break;
		case 8:
			echo '上传的文件被PHP拓展程序中断';
			break;
	}
}


?>